load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "jobspb",
    srcs = [
        "jobs.go",
        "schedule.go",
        "wrap.go",
    ],
    embed = [":jobspb_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/jobs/jobspb",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/sql/catalog/catpb",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/protoreflect",
        "//pkg/util/tracing/tracingpb",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_gogo_protobuf//jsonpb",
    ],
)

proto_library(
    name = "jobspb_proto",
    srcs = [
        "jobs.proto",
        "schedule.proto",
    ],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/clusterversion:clusterversion_proto",
        "//pkg/kv/kvpb:kvpb_proto",
        "//pkg/multitenant/mtinfopb:mtinfopb_proto",
        "//pkg/roachpb:roachpb_proto",
        "//pkg/sql/catalog/catpb:catpb_proto",
        "//pkg/sql/catalog/descpb:descpb_proto",
        "//pkg/sql/sessiondatapb:sessiondatapb_proto",
        "//pkg/util/hlc:hlc_proto",
        "//pkg/util/tracing/tracingpb:tracingpb_proto",
        "@com_github_cockroachdb_errors//errorspb:errorspb_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
        "@com_google_protobuf//:any_proto",
        "@com_google_protobuf//:timestamp_proto",
    ],
)

go_proto_library(
    name = "jobspb_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/jobs/jobspb",
    proto = ":jobspb_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/clusterversion",
        "//pkg/kv/kvpb",
        "//pkg/multitenant/mtinfopb",
        "//pkg/roachpb",
        "//pkg/security/username",  # keep
        "//pkg/sql/catalog/catpb",  # keep
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/sem/tree",  # keep
        "//pkg/sql/sessiondatapb",
        "//pkg/util/hlc",
        "//pkg/util/tracing/tracingpb",  # keep
        "//pkg/util/uuid",  # keep
        "@com_github_cockroachdb_errors//errorspb",
        "@com_github_gogo_protobuf//gogoproto",
    ],
)

go_test(
    name = "jobspb_test",
    srcs = ["wrap_test.go"],
    deps = [
        ":jobspb",
        "@com_github_stretchr_testify//assert",
    ],
)
